﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dropbox
{
    public partial class DropboxOAuthToken
    {

        public DropboxOAuthToken(string result)
        {
            originalString = result;

            var items = result.Split('&');
            if (items.Count() > 0)
            {
                foreach (var item in items)
                {
                    var kvp = item.Split('=');
                    if (kvp.Count() > 0)
                        switch (kvp[0].ToLowerInvariant())
                        {
                            case "oauth_token":
                                Token = kvp[1];
                                break;
                            case "oauth_token_secret":
                                Secret = kvp[1];
                                break;
                            default:
                                break;
                        }
                }
            }
        }

        private string originalString;
        public string Token { get; private set; }
        public string Secret { get; private set; }

        public override string ToString()
        {
            return originalString;
        }
    }
}
